package gazzera.node.core.messages;

import java.io.*;

public class Hello extends Message
{
	public int majorVersion;
	public int minorVersion;
	public String hash = null;
	public String nickname = null;
	public int port = 0;
	public String dynhost = null;
	public String extra1 = null;
	public String extra2 = null;

	public Hello()
	{
		super();
	}

	public Hello(int majorVersion, int minorVersion, String hash, String nickname, int port, String dynhost, String extra1, String extra2)
	{
		super();
		this.majorVersion = majorVersion;
		this.minorVersion = minorVersion;
		this.hash = hash;
		this.nickname = nickname;
		this.port = port;
		this.dynhost = dynhost;
		this.extra1 = extra1;
		this.extra2 = extra2;
	}

	protected void send(DataOutputStream s) throws IOException
	{
		sendInt(s, majorVersion);
		sendInt(s, minorVersion);
		sendString(s, hash);
		sendString(s, nickname);
		sendInt(s, port);
		sendString(s, dynhost);
		sendString(s, extra1);
		sendString(s, extra2);

	}

	protected void recv(DataInputStream s) throws IOException
	{
		majorVersion = readInt(s);
		minorVersion = readInt(s);
		hash = readString(s);
		nickname = readString(s);
		port = readInt(s);
		dynhost = readString(s);
		extra1 = readString(s);
		extra2 = readString(s);

	}

}
